﻿using HomagGroup.Base.UI;
using HomagGroup.Base.UI.Themes.Resources;
using Proxy;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using static HomagChina.Nesting.ProcessResourceInternal;
using static HomagChina.Nesting.Router.Utility;
using Application = System.Windows.Application;
using localText = PropertiesLibarary.Properties.Resources;
using MenuItem = HomagGroup.Base.UI.Controls.MenuItem;
using UserControl = System.Windows.Controls.UserControl;

namespace HomagChina.Nesting
{
    public class ErrorMessageRoute
    {
        private CommonHandle Handle_Common;
        private SearchInfoHandle Handle_Search;
        private static UserControl userC;
        private static ErrorMessageViewModel errorMessageViewModel;

        public RouterItemDataModel ErrorMessageRouteModel { get; set; }

        public ErrorMessageRoute(MainWindowViewModel baseViewModel, bool isInit)
        {
            Handle_Common = new CommonHandle();
            Handle_Search = new SearchInfoHandle();
            if (isInit)
            {
                errorMessageViewModel = (ErrorMessageViewModel)GetViewModelInstance("ErrorMessageViewModel");
                userC = (UserControl)GetUserControlInstance("ErrorMessage");
            }
            ErrorMessageRouteModel = new RouterItemDataModel()
            {
                ID = "4",
                viewLabel = localText.Error_message,
                viewName = "ErrorMessage",
                viewModelName = "ErrorMessageViewModel",
                ViewModel = errorMessageViewModel,
                keepalive = false,
                userControl = userC,
                Image = null,
                functionKeyBarItems = new ObservableCollection<FunctionKeyBarItemDataModel>{
                    new FunctionKeyBarItemDataModel() {
                        Header =localText.Filter_off , Position = 9,  Icon = GetIconBrush(Icon.ViewGrid,overlayIcon:OverlayIcon.Check),
                        Command=new RelayCommand(errorMessageViewModel.HandleIsShowFilter)
                    },
                    new FunctionKeyBarItemDataModel() {
                        Header =localText.Extras, Position = 10, Icon = GetIconBrush(Icon.More, overlayIcon: OverlayIcon.None),MenuItems = new List<MenuItem>
                    {
                        new MenuItem { Header = localText.Settings, Icon =GetResourceBrush("items") },
                        new MenuItem { Header = localText.Create_service_file, Icon= GetResourceBrush("TableSettingsImage")  }
                    }},
                    new FunctionKeyBarItemDataModel(){
                        Header = localText.Advanced,Position = 8, Icon = GetResourceBrush("Advanced"),  MenuItems = new List<MenuItem>
                        {
                            new MenuItem { Header = localText.Freeze,IsCheckable = true,
                                Command = new RelayCommand(errorMessageViewModel.HandleIsFreeze) },
                            new MenuItem { Header = localText.History ,IsCheckable = true,
                                Command = new RelayCommand(errorMessageViewModel.HandleIsHistory)}
                        }
                    },
                    new FunctionKeyBarItemDataModel() {
                        Header = localText.Exit, Position = 12, Icon = GetIconBrush(Icon.Close, ImageDecoration.Circle),
                        Command = new RelayCommand(() => { Application.Current.Shutdown(); })
                    },
                    new FunctionKeyBarItemDataModel() {
                        Header = localText.Error_message, Position = 11, Icon = GetResourceBrush("ErrorMessages"),
                        Command = new RelayCommand(baseViewModel.NavigateToExecute),CommandParameter = "4"
                    },
                    new FunctionKeyBarItemDataModel() {
                        Header = localText.Info, Position = 1, Icon = GetIconBrush(Icon.Information, imageDecoration: ImageDecoration.Circle),
                        Command = new RelayCommand(() => { Handle_Common.OpenInformationCommand(Handle_Search.GetSystemInfoMation()); })
                    }
                }
            };
        }
    }
}